home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
madtrb4.arc
/
ALLFILES.LIB
next >
Wrap
Text File
|
1984-12-21
|
7KB
|
177 lines
{@@@@@@@@@@@@@@@@@@@ copyright 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@
ALLFILES(ulCol, ulRow, lrCol, lrRow : byte;
VAR template : filename_type;
VAR error_return : byte);
Pass the UpperLeft and LowerRight corners of the window in which selection
is to take place and the template (e.g., 'c:\whammy\*.*') of the files to
be scanned. Returns the selected filename in "template", or an error code.
The width of the window must be at least 18 characters--36 gives two columns.
If the user "breaks out" of the selection process by pressing <Esc>, the
error return code is set to 255.
REQUIRES : filename.typ
regpack.typ
getkeys.lib
monitor.lib
screen.lib
getfile.lib
These files must also be INCLUDEd in a program that uses ALLFILES.
}
{@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
procedure Frame(ulC, ulR, lrC, lrR: byte); { Upper Left and Lower Right
Row and Column }
var
I:byte;
begin
GotoXY(ulC, ulR); Write(chr(201));
for I:=ulC+1 to lrC-1 do Write(chr(205));
Write(chr(187));
for I:=ulR+1 to lrR-1 do
begin
GotoXY(ulC , I); Write(chr(186));
GotoXY(lrC, I); Write(chr(186));
end;
GotoXY(ulC, lrR);
Write(chr(200));
for i:=ulC+1 to lrC-1 do Write(chr(205));
Write(chr(188));
end;
{@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
procedure AllFiles(ulCol, ulRow, lrCol, lrRow : byte;
VAR template : filename_type;
VAR error_return : byte);
var
OneChar, choice, EscChoice : char;
attrib, error, margin, count, HowDeep : byte;
{-------------------------------------------------------------------}
procedure Do_select(VAR name : filename_type);
var
N, X, Y, loc : byte;
{----------------------------------------------------------}
procedure transloc(loc:byte; var X,Y:byte); { translates a numeric }
begin { location ("7th file") }
X := ((loc-1) div (howDeep-1))*18 + ulCol; { into X and Y coordin- }
Y := (loc-1) mod (howDeep-1) + ulRow; { ates and writes a }
WriteScreen(X,Y,chr(16),112); { pointer at those }
end; { coordinates. }
{----------------------------------------------------------}
begin
loc := 1;
transloc(loc,X,Y);
gotoXY(X-ulCol+1,Y-ulRow+1); { This line keeps the normal cursor
in the same place as the pointer. }
repeat
getKeys(choice, EscChoice);
if choice = chr(27) then
begin
case EscChoice of
'H': begin
WriteScreen(X,Y,' ',15);
if loc > 1 then loc := loc - 1 else loc := count;
transloc(loc,X,Y);
end;
{ UP arrrow. If the LOCation is any but the first, it
just decrements by one. If it's the first, it becomes
the last. Thus there's a "wrap" effect. }
'P': begin
WriteScreen(X,Y,' ',15);
if loc < count then loc := loc + 1 else loc := 1;
transloc(loc,X,Y);
end;
{ DOWN arrow. Increments LOCation by one. If already
at the end, "wraps" to beginning. }
'K': begin
WriteScreen(X,Y,' ',15);
if loc > (howDeep - 1) then loc := loc - (howDeep - 1) else
begin
loc := loc + 5*(howDeep-1);
while loc > count do loc := loc - (howDeep - 1);
end;
transloc(loc,X,Y);
end;
{ LEFT arrow. Moves to same screen line one column to
the left. If already at leftmost column, goes to far
right column. }
'M': begin
WriteScreen(X,Y,' ',15);
loc := loc + HowDeep - 1;
if loc > count then loc := loc mod (HowDeep - 1) ;
if loc = 0 then loc := HowDeep - 1;
transloc(loc,X,Y);
end;
{ RIGHT arrow. Moves to same screen line one column to
the right. If already at rightmost, goes to far left. }
end; {case}
GotoXY(X-ulCol+1,Y-ulRow+1); { Put the normal cursor in the
same place as the pointer. }
end; { if }
until (choice = #13) or ((choice = #27) and (EscChoice = #0));
if choice = #27 then error_return := 255;
name := '';
{ Now we pick the selected name right off the screen. }
for N := 1 to 13 do
begin
oneChar := ReadScreen(X+N,Y);
if not (oneChar in [#0,#32]) then name := name + oneChar;
end;
window(ulCol-1,ulRow-2,lrCol+1,lrRow+1);
ClrScr;
window(1,1,80,25);
end;
{-------------------------------------------------------------------}
begin
GotoXY(ulCol,ulRow-1);ClrEOL;
Write('Move w/ arrows, select w/ <Return>');
frame(ulCol-1,ulRow-2,lrCol+1,lrRow+1);
window(ulCol,ulRow,lrCol,lrRow);
ClrScr;
howDeep := lrRow - ulRow;
attrib := 32;
buffer.name := ' ';
Find_First(attrib, template, error);
error_return := error;
if error = 0 then
begin
count := 1;
margin := 2;
GotoXy(margin,WhereY);
WriteLn(template);
repeat
buffer.name := ' ';
find_Next(attrib,template,error);
if error = 0 then
begin
gotoXY(margin,WhereY);
writeLn(template);
count := count + 1;
if WhereY > HowDeep-1 then
begin
margin := margin + 18;
gotoXY(margin,1);
end;
if count >= ((HowDeep-1)*(((lrCol-ulCol) div 18))) then
begin
GotoXY(1,HowDeep);
Write('Any key to see more, <CR> to stay');
GetKeys(choice,EscChoice);
gotoXY(1,HowDeep);ClrEOL;
if choice = #13 then error := 1
else
begin
ClrScr;
count := 0;
margin := 2;
end;
end;
end;
until error <> 0;
do_select(template);
end;
end;